package chen.web.forum.event;

import chen.web.IdEntity;
import chen.web.event.Event;
import chen.web.forum.Reply;
import chen.web.forum.Subject;

public abstract class BasePostEvent implements Event{
	private IdEntity entity;
	
	protected BasePostEvent(IdEntity entity){
		this.entity = entity;
	}
	
	public PostType getPostType() {
		if(entity == null){
			throw new NullPointerException();
		}
		if(entity instanceof Subject){
			return PostType.Subject;
		} else if(entity instanceof Reply){
			return PostType.Reply;
		} else {
			throw new RuntimeException("程序错误, 此事件仅支持主题和回复的实例");
		}
	}

	public IdEntity getEntity() {
		return entity;
	}

	public void setEntity(IdEntity entity) {
		this.entity = entity;
	}
}
